<template>
  <div id="person">
    <div class="person-con">
      <!-- 因为子元素用了浮动，所以父元素要清除浮动，才可以自动撑开 -->
      <div class="person-all clearfix">

        <!-- 左边导航条 -->
        <div class="person-aside">
            <div class="person-aside-all" @click="getAsideIndex">

              <div class="aside-title1" @click = "asideIndex = 1">
                <div><i class="iconfont icon-yonghudianji"></i>个人中心</div>
              </div>

              <div class="aside-title2" @click="change2();asideIndex = 2">
                <div><i class="iconfont icon-daohang"></i>
                 <span class="iconfont icon-daohang-text">招商中心</span>
                <i class="iconfont icon-xiangshang" v-show = "navBool"></i>
                <i class="iconfont icon-xiangxia" v-show = "!navBool"></i>
                </div>
              </div>
              
              <div class="aside-title2-con" v-if = "navBool">
                <transition name="fade">
                <div class="aside-title-list" @click="asideIndex=2">发布推广</div>
                 </transition>
                <transition name="fade">
                 <div class="aside-title-list" @click="asideIndex=3">商品管理</div>
                 </transition>
              </div>

            </div>
        </div>

        <!-- 右边所有的内容 -->
        <div class="person-container-all">
          <div class="person-container">
            <!-- 右边内容 -->
            <div class="right-con clearfix">
                <!-- 个人中心模板 -->
                <div v-show="asideIndex==1" class="person-template">
                    <h1 class="right-h3">个人中心</h1>
                    <div class="right-info">
                        <div class="right-touxiang">

                            <div class="touxiang-img">
                              <div class="touxiang-img-con">
                                <img src="../img/01.jpg" alt="">
                              </div>
                            </div>
                            <div class="touxiang-text-con">
                              <div class="text-con1">1008610086</div>
                              <div class="text-con2">一入驻20天</div>
                              <div class="text-con3">
                                <img src="../img/write.png" alt="">
                              </div>
                            </div>
                        </div>
                        
                        <div class="right-jifen">
                            
                            <div class="jifen-btn">
                              <span>充值</span>
                            </div>
                            <div class="jifen-text">
                              <span class="jifen-text-con">
                                <span class="text-num">0</span>
                                积分
                              </span> 
                            </div>
                        </div>
                    </div>

                    <!--三个板块 -->
                    <div class="four-con">
                      <div class="four-con-one">
                          <div class="con-one-text">
                            <div class="one-text-left">
                                <img src="../img/person_03.jpg" alt="">
                            </div>
                            <div class="one-text-right">
                              发布推广
                            </div>
                          </div>
                      </div>
                      <div class="four-con-one">
                        <div class="con-one-text">
                            <div class="one-text-left">
                                <img src="../img/person_05.jpg" alt="">
                            </div>
                            <div class="one-text-right">
                              充值中心
                            </div>
                          </div>
                      </div>
                      <div class="four-con-one">
                        <div class="con-one-text">
                            <div class="one-text-left">
                                <img src="../img/person_07.jpg" alt="">
                            </div>
                            <div class="one-text-right">
                              账户设置
                            </div>
                          </div>
                      </div>
                    </div>

                    <!-- 空元素撑开页面 -->
                    <div class="noCon">
                    </div>
                </div>
                <!-- 招商放单模板 -->
                <div v-show="asideIndex==2 && !isApply" class="apply-template">
                  <h1 class="right-h3">招商放单申请</h1>
                  <!-- 选项 -->
                  <div class="apply-radio">
                    <template>
                      <el-radio v-model="attractData.radio" label="1">个人</el-radio>
                      <el-radio v-model="attractData.radio" label="2">团队</el-radio>
                    </template>
                  </div>
                  <!-- 个人/团队名称 -->
                  <div class="apply-teamName">
                    <div class="teamName-left">个人/团队名称:</div>
                    <div class="teamName-middle">
                      <el-input v-model="attractData.teamName" style="width:40%;" placeholder="请写2~6个汉字或4~8个字符"></el-input>
                    </div>
                    <div class="teamName-right">
                    </div>
                  </div>

                  <!-- QQ号 -->
                  <div class="apply-teamName">
                    <div class="teamName-left">QQ号:</div>
                    <div class="teamName-middle">
                      <el-input v-model="attractData.teamQQ" style="width:40%;" placeholder="请填写常用号"></el-input>
                    </div>
                    <div class="teamName-right">
                    </div>
                  </div>

                  <!-- 微信号 -->
                  <div class="apply-teamName">
                    <div class="teamName-left">微信号:</div>
                    <div class="teamName-middle">
                      <el-input v-model="attractData.teamWx" style="width:40%;" placeholder="请填写常用号"></el-input>
                    </div>
                    <div class="teamName-right">
                    </div>
                  </div>

                  <!-- 月收入 -->
                  <div class="apply-teamName">
                    <div class="teamName-left">月收入:</div>
                    <div class="teamName-middle">
                      <el-input v-model="attractData.monthMoney" style="width:40%;" placeholder=""></el-input>
                    </div>
                    <div class="teamName-right">
                    </div>
                  </div>

                   <!-- 导购文案 -->
                  <div class="apply-copywriter">
                    <div class="copywriter-left">个人/团队介绍:</div>
                    <div class="copywriter-middle">
                      <template>
                        <el-input
                            type="textarea"
                            :autosize="{ minRows: 6, maxRows: 10}"
                            placeholder="请填写个人/团队信息"
                            v-model="attractData.teamText"
                            >
                          </el-input>
                      </template>
                    </div>
                    <div class="copywriter-right">
                    </div>
                  </div>
                  <!-- 确认提交按钮 -->
                  <div class="apply-submit">
                    <div class="submit-left"></div>
                    <div class="submit-middle">
                      <input @click="getAddData"  type="button" value="确认提交">
                    </div>
                    <div class="submit-right">
                    </div>
                  </div>

                </div>
                <!-- 发布推广模板 -->
                <div v-show="asideIndex==2 && isApply" class="issue-template">
                  <h1 class="right-h3">发布推广</h1>
                  <!-- 商品链接 -->
                  <div class="shop-link-con">
                    <div class="link-con-left">商品链接:</div>
                    <div class="link-con-middle">
                      <el-input v-model="duoDuoLink" placeholder="请输入商品链接"></el-input>
                      <!-- <input v-model="duoDuoLink" type="text" placeholder="请输入商品链接"> -->
                    </div>
                    <div class="link-con-right">
                      <input @click="getDuoDuoData()" type="button" value="获取信息">
                    </div>
                  </div>

                  <!-- 判断是否已经发布了才可以展示 -->
                  <div v-show="isIssue" class="isIssue-template">
                    <!-- 商品图片展示  发布了才可以看到-->
                    <div  class="shop-show">

                      <div class="show-left">图片展示:</div>

                      <div class="show-img-con">
                        <div class="img-con" v-for="(item,index) in addShopData.goods_gallery_urls" :key="index">
                          <img :src=item alt="">
                        </div>
                      </div>

                      <div class="show-right"></div>
                    </div>

                    <!-- 商品标题 发布了才可以看到-->
                    <div class="shop-title">
                      <div class="title-left">商品标题:</div>
                      <div class="title-middle">
                        <el-input v-model="addShopData.goods_name" placeholder="请输入商品短标题"></el-input>
                        <!-- <input type="text" placeholder="请输入商品标题"> -->
                      </div>
                      <div class="title-right">
                      </div>
                    </div>

                    <!-- 所属分类 发布了才可以看到-->
                    <div class="shop-class">
                      <div class="class-left">所属分类:</div>
                      <div class="class-middle">
                        <template>
                          <el-select v-model="addShopData.category_name" placeholder="请选择分类">
                            <el-option
                              v-for="item in options"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value">
                            </el-option>
                          </el-select>
                        </template>
                      </div>
                      <div class="class-right">
                      </div>
                    </div>

                    <!-- 商品评分 发布了才可以看到-->
                    <div class="shop-score">
                      <div class="score-left">
                        <div class="score-left-text">商品评分:</div>
                        <div class="score-left-con">
                          <div class="score-left-input">
                            <input v-model="addShopData.goods_eval_score" type="text" value="4.50">
                          </div>
                        </div>
                        <span class="score-span">分</span>
                      </div>
                      <div class="score-middle">
                      </div>
                      <div class="score-right">
                      </div>
                    </div>

                    <!-- 商品销量 发布了才可以看到-->
                    <div class="shop-sales">

                      <div class="sales-left">
                        <div class="sales-left-text">销量:</div>
                        <div class="sales-left-con">
                          <div class="sales-left-input">
                            <input v-model="addShopData.sales_tip" type="text" value="15646">
                          </div>
                        </div>
                        <span class="sales-span"></span>
                      </div>
                      
                      <div class="sales-left">
                        <div class="sales-left-text">厂家建议零售价:</div>
                        <div class="sales-left-con">
                          <div class="sales-left-input">
                            <input v-model="addShopData.min_group_price"  type="text" value="9.9">
                          </div>
                        </div>
                        <span class="sales-span"></span>
                      </div>

                      <div class="sales-left">
                        <div class="sales-left-text">券后价:</div>
                          <div class="sales-left-con">
                            <div class="sales-left-input">
                              <input v-model = "addShopData.goods_postCouponPrice"  type="text" value="0.0">
                            </div>
                          </div>
                          <span class="sales-span"></span>
                      </div>
                    </div>

                    <!-- 优惠券金额 发布了才可以看到-->
                    <div class="shop-sales">

                      <div class="sales-left">
                        <div class="sales-left-text">优惠券金额:</div>
                        <div class="sales-left-con">
                          <div class="sales-left-input">
                            <input v-model="addShopData.coupon_discount" type="text" value="1">
                          </div>
                        </div>
                        <span class="sales-span">元</span>
                      </div>
                      
                      <div class="sales-left">
                        <div class="sales-left-text">优惠券总数:</div>
                        <div class="sales-left-con">
                          <div class="sales-left-input">
                            <input v-model="addShopData.coupon_total_quantity" type="text" value="1000">
                          </div>
                        </div>
                        <span class="sales-span"></span>
                      </div>

                      <div class="sales-left">
                        <div class="sales-left-text">优惠券剩余:</div>
                          <div class="sales-left-con">
                            <div class="sales-left-input">
                              <input v-model="addShopData.coupon_remain_quantity" type="text" value="456">
                            </div>
                          </div>
                          <span class="sales-span"></span>
                      </div>
                    </div>

                    <!-- 佣金比例 发布了才可以看到-->
                    <div class="shop-sales">

                      <div class="sales-left">
                        <div class="sales-left-text">佣金比例:</div>
                        <div class="sales-left-con">
                          <div class="sales-left-input">
                            <input v-model="addShopData.promotion_rate" type="text" value="30">
                          </div>
                        </div>
                        <span class="sales-span">%</span>
                      </div>
                      
                      <div class="sales-left">
                      </div>

                      <div class="sales-left">
                      </div>
                    </div>

                    <!-- 优惠券开始时间 发布了才可以看到-->
                    <div class="shop-sales">
                      <div class="sales-left">
                        <div class="sales-left-text">优惠券开始时间:</div>
                        <div class="sales-left-con">
                          <div class="sales-left-input">
                            <!-- <div class="block">
                              <el-date-picker
                                v-model="addShopData.couponStartTime"
                                type="datetimerange"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                :default-time="['12:00:00']">
                              </el-date-picker>
                            </div> -->
                            <input v-model="addShopData.coupon_start_time" type="text" value="startTime">
                          </div>
                        </div>
                        <span class="sales-span"></span>
                      </div>
                      
                      <div class="sales-left">
                        <div class="sales-left-text">优惠券结束时间:</div>
                        <div class="sales-left-con">
                          <div class="sales-left-input">
                            <input v-model="addShopData.coupon_end_time" type="text" value="2019-04-26 12:00">
                          </div>
                        </div>
                        <span class="sales-span"></span>
                      </div>

                      <div class="sales-left">
                      </div>
                    </div>

                    <!-- 导购文案 发布了才可以看到-->
                    <div class="shop-copywriter">
                      <div class="copywriter-left">导购文案:</div>
                      <div class="copywriter-middle">
                        <template>
                          <el-input
                              type="textarea"
                              :autosize="{ minRows: 6, maxRows: 10}"
                              placeholder="请输入导购文案"
                              v-model="addShopData.goods_desc"
                              >
                            </el-input>
                        </template>
                      </div>
                      <div class="copywriter-right">
                      </div>
                    </div>
                    <!-- 确认提交按钮 发布了才可以看到-->
                    <div class="shop-submit">
                      <div class="submit-left"></div>
                      <div class="submit-middle">
                        <!-- 提交添加商品 -->
                        <input @click="getAllInofData"  type="button" value="确认提交">
                      </div>
                      <div class="submit-right">
                      </div>
                    </div>

                  </div>

                </div>

                <!-- 商品管理 -->
                <div v-show="asideIndex==3" class="manage-template">
                    <h1 class="right-h3" >商品管理</h1>
                    <!-- 搜索商品 -->
                    <div class="manage-link-con">
                      <div class="manage-con-middle">
                        <el-input ref="shopName" v-model="inputShop" placeholder="请输入商品名称"></el-input>
                        <!-- <input type="text" placeholder="请输入商品链接"> -->
                      </div>
                      <div class="manage-con-right">
                        <input @click="getSelectData" type="button" value="搜索">
                      </div>
                    </div>

                    <!-- 分类搜索 -->
                    <div class="class-link-con">
                      <div class="class-con-right">
                        <input type="button" value="全部" :class="{navClass:navNum == 1}" @click="navNum = 1">
                      </div>
                      <div class="class-con-right">
                        <input type="button" :value="arrList.num1" :class="{navClass:navNum == 2}" @click="navNum = 2">
                      </div>
                      <div class="class-con-right">
                        <input type="button" :value="arrList.num2" :class="{navClass:navNum == 3}" @click="navNum = 3">
                      </div>
                      <div class="class-con-right">
                        <input type="button" :value="arrList.num3" :class="{navClass:navNum == 4}" @click="navNum = 4">
                      </div>
                      <div class="class-con-right">
                        <input type="button" :value="arrList.num4" :class="{navClass:navNum == 5}" @click="navNum = 5">
                      </div>
                    </div>

                    <!-- 分类展示 -->
                    <div class="classShow-link-con">
                      <div class="classShow-con-right">
                        <input type="button" value="商品">
                      </div>
                      <div class="classShow-con-right">
                        <input type="button" value="券后价">
                      </div>
                      <div class="classShow-con-right">
                        <input type="button" value="优惠券信息">
                      </div>
                      <div class="classShow-con-right">
                        <input type="button" value="佣金比例">
                      </div>
                      <div class="classShow-con-right">
                        <input type="button" value="时间">
                      </div>
                      <div class="classShow-con-right">
                        <input type="button" value="积分">
                      </div>
                    </div>
                    <!-- 分类展示 内容-->
                    <div class="classList-link-con" v-for="(item,index) in guangLiData" :key="index">
                      <div class="classShow-con-right" >
                        <div class="con-right-img">
                          <img :src="item.goods_thumbnail_url" alt="">
                        </div>
                      </div>
                      <div class="classShow-con-right">
                        <div><p>￥{{item.goods_postCouponPrice/100}}</p></div>
                      </div>
                      <div class="classShow-con-right">
                        <div>{{item.coupon_remain_quantity}}</div>
                      </div>
                      <div class="classShow-con-right">
                        <div>{{item.promotion_rate/100}}%</div>
                      </div>
                      <div class="classShow-con-right">
                        <div>{{item.coupon_end_time}}</div>
                      </div>
                       <div class="classShow-con-right">
                        <input type="button" value="5">
                      </div>
                    </div>

                    <!-- 没有商品提示 -->
                    <div class="noShop-tip" v-show="guangLiData==''">
                      <div class="noShop-tip-text">小主还没有商品呢，快去发布推广吧！</div>
                    </div>

                    <!-- 撑开页面元素 -->
                    <div class="noCon"></div>
                </div>

            </div>
          </div>

        </div>

      </div>
    </div>

  </div>
</template>

<script>
import "../scss/person.scss";
import qs from 'qs';

export default {
  created () {
    var getToken = this.ApiCookie.getCookie('data');
    var getApply = this.ApiStorage.get('apply');
    // 判断如果有
    // getToken
    if(getToken){  // 假设有缓存
        this.token = getToken;
        this.isLogin = true;
        // 检查是否已申请招商
        /* this.getAttract();
        this.getGoodsData();*/
    }
    // 判断是否已经申请了
    if(getApply){
      this.isApply = true;
    }
    // 首次进入页面显示的内容下标
    this.asideIndex = 2;
    // this.addShopData.couponStarTime = this.checkTime(1556207999);
  },
  data(){
    return {
      // 商品管理分类数据
      arrList:{
        num1:'展示(3)',
        num2:'待审核(5)',
        num3:'拒绝(6)',
        num4:'已下架(7)',
      },
      // 时间
      value1: '',
      // 导航条样式
      navNum:'1',
      // 下来框布尔值
      navBool:false,
      //招商中心数据
      attractData:{
        // radio 个人还是团队
        radio:'1',
        // teamName 个人或团队名称
        teamName:'',
        // teamQQ
        teamQQ:'',
        teamWx:'',
        monthMoney:'',
        teamText:'',
      },
      // 添加商品数据
      addShopData:{
        goods_name: "", //商品标题
        goods_id: "",//商品id
        goods_thumbnail_url: "",//商品主图
        goods_gallery_urls: null,//商品轮播图
        mall_name: null,//店铺名称
        category_id: null,//商品类目ID
        category_name: null,//商品类目名
        goods_eval_score: '',//商品评分
        min_group_price: '',//商品原价
        coupon_discount: "",//优惠券面额
        coupon_total_quantity: '',//优惠券总数量
        promotion_rate: "",//佣金比例
        sales_tip: "",//模糊销量（总数）
        goods_postCouponPrice: "",//劵后价
        coupon_remain_quantity: '',//优惠劵剩余
        coupon_start_time: '',//优惠券生效时间
        coupon_end_time: '',//优惠券失效时间
        goods_desc: "",//导购文案
        goods_whether: '',//当goods\_whether等于1的时候 单子通过 当等于0的时候单子不通过2等于待审核3是已下架
        user_id: '',//用户id
        admin_id: null,//审核人的id
        time: ""//提交时间
      },
      // 管理商品数据
      guangLiData:'',
      // 是否确定已通过申请,默认为为false
      isApply:false,
      // 判断是否商品已发布
      isIssue:true,
      // 商品链接存在
      shopLink:'',
      // token
      token:'',
      // 添加商品对象
      addData:{
        
      },
      // 获取左边导航的下标
      asideIndex:'1',
      value: '',
      asideIndex:'1',
      input:'',

      // 导购文案变量
      textarea3:'',
      // 拼多多的产品链接
      duoDuoLink:'',
      // 商品id
      duoDuoLinkId:'',
      // 保存产品所有数据
      duoDuoData:'',
      // 计算后的数据
      proData:'',

      // 下拉框内容
      options: [{
          value: '1',
          label: '美食'
        }, {
          value: '2',
          label: '母婴'
        }, {
          value: '3',
          label: '水果'
        }, {
          value: '4',
          label: '服饰'
        }, {
          value: '5',
          label: '百货'
        }, {
          value: '6',
          label: '美妆'
        }, {
          value: '7',
          label: '电器'
        }, {
          value: '8',
          label: '男装'
        }
        , {
          value: '9',
          label: '其他'
        }],
        // 商品管理的输入值
        inputShop:'',
        // 时间开始值
        startTime:'',
    }
  },
  computed:{
    
  },
  methods: {
    changeTime(time){
      //补0
      function getBz(num){
          if(parseInt(num) < 10){
              num = '0'+num;
          }
          return num;
      }  
      if(time){
        var oDate = new Date(time*1),
            oYear = oDate.getFullYear(),
            oMonth = oDate.getMonth()+1,
            oDay = oDate.getDate(),
            oHour = oDate.getHours(),
            oMin = oDate.getMinutes(),
            oSen = oDate.getSeconds(),
            oTime = oYear +'-'+ getBz(oMonth) +'-'+ getBz(oDay) +' '+ getBz(oHour) +':'+ getBz(oMin) +':'+getBz(oSen);//拼接时间
            return oTime;
        }else{
            return "";
        }
    },
    // 获取拼多多的产品数据
    getDuoDuoData(){
      let newStr = this.ApiUtils.ApiStr.getStrLeft(this.duoDuoLink,0,40);
      if(newStr == 'https://mobile.yangkeduo.com/goods2.html'){
        console.log('输入格式正确');
      }else{
        console.log('输入格式不正确');
      }
      console.log('经过截取后的字符串',newStr);
      console.log('输出字符串',this.duoDuoLink,'截取字符串',this.duoDuoLink.Right(10));
      this.duoDuoLinkId = this.duoDuoLink.Right(10);
      let mytime = 1534301216395;
      mytime = this.changeTime(mytime);
      console.log('测试时间转换',mytime);
        /* this.axios.get("https://api.weapp.duoduocr.com/data/goods_detail",{
                params:{
                  goods_id_list:this.duoDuoLinkId,
                }
            }).then(res => {
            console.log("获取拼多多产品数据：", res);
            // 保存数据
            let duoDuoDataList = res.data.goods_detail_response.goods_details;
            // console.log('保存所有产品数据',this.duoDuoData);
            for(let i=0;i<duoDuoDataList.length;i++){
              if(i==0){
                this.duoDuoData = duoDuoDataList[0];
              }
            }
            // 预先计算数值再赋值
            this.duoDuoData.promotion_rate = this.duoDuoData.promotion_rate/100;
            this.duoDuoData.coupon_discount = this.duoDuoData.coupon_discount/100;
            this.duoDuoData.coupon_start_time = this.duoDuoData.coupon_start_time;
            console.log('转换时间格式',this.duoDuoData.coupon_start_time);
            console.log('保存产品数据',this.duoDuoData);
              // 商品标题
              this.addShopData.goods_name = this.duoDuoData.goods_name ; //商品标题
              this.addShopData.goods_id = this.duoDuoData.goods_id  ;//商品id
              this.addShopData.goods_thumbnail_url = this.duoDuoData.goods_thumbnail_url ;//商品主图
              this.addShopData.goods_gallery_urls = this.duoDuoData.goods_gallery_urls; // null;//商品轮播图
              this.addShopData.mall_name = this.duoDuoData.mall_name; // null;//店铺名称
              this.addShopData.category_id = this.duoDuoData.category_id; // null;//商品类目ID
              this.addShopData.category_name = this.duoDuoData.category_name; // null;//商品类目名
              this.addShopData.goods_eval_score = this.duoDuoData.goods_eval_score; // 5;//商品评分
              this.addShopData.min_group_price = this.duoDuoData.min_group_price; //3250;//商品原价
              this.addShopData.coupon_discount = this.duoDuoData.coupon_discount; //"30";//优惠券金额
              this.addShopData.coupon_total_quantity = this.duoDuoData.coupon_total_quantity; //1000;//优惠券总数量
              this.addShopData.promotion_rate = this.duoDuoData.promotion_rate; // "200";//佣金比例
              this.addShopData.sales_tip = this.duoDuoData.sales_tip; //"500";//模糊销量（总数）
              this.addShopData.goods_postCouponPrice = this.duoDuoData.goods_postCouponPrice; //"500";//劵后价
              this.addShopData.coupon_remain_quantity = this.duoDuoData.coupon_remain_quantity; // 300;//优惠劵剩余
              this.addShopData.coupon_start_time = this.duoDuoData.coupon_start_time;// 1556035200;//优惠券生效时间
              this.addShopData.coupon_end_time = this.duoDuoData.coupon_end_time; //1556207999;//优惠券失效时间
              this.addShopData.goods_desc = this.duoDuoData.goods_desc;// "口罩";//导购文案
              this.addShopData.goods_whether = this.duoDuoData.goods_whether;// 2;//当goods\_whether等于1的时候 单子通过 当等于0的时候单子不通过2等于待审核3是已下架
              this.addShopData.user_id = this.duoDuoData.user_id; //18;//用户id
              this.addShopData.admin_id = this.duoDuoData.admin_id; //null;//审核人的id
              // this.addShopData.time:this.duoDuoData "2019-04-24 14:34:47"//提交时间
              console.log('保存addShopData的数据',this.addShopData,'duoDuoData的图片组',this.duoDuoData);
        }); */
      this.axios.post("/getyzm/data/goods_detail",{
            goods_id_list:this.duoDuoLinkId,
          }).then(res => {
          console.log("获取拼多多产品数据：", res);
          // 显示产品参数
          this.isIssue = true;
          let duoDuoDataList = res.data.goods_detail_response.goods_details;
          // console.log('保存所有产品数据',this.duoDuoData);
          for(let i=0;i<duoDuoDataList.length;i++){
            if(i==0){
              this.duoDuoData = duoDuoDataList[0];
            }
          }
          // 预先计算数值再赋值
          this.duoDuoData.promotion_rate = this.duoDuoData.promotion_rate/100;
          this.duoDuoData.coupon_discount = this.duoDuoData.coupon_discount/100;
          this.duoDuoData.min_group_price = this.duoDuoData.min_group_price/100;

          console.log('保存产品数据',this.duoDuoData);
            // 商品标题
            this.addShopData.goods_name = this.duoDuoData.goods_name ; //!商品标题
            this.addShopData.goods_id = this.duoDuoData.goods_id  ;//!商品id
            this.addShopData.goods_thumbnail_url = this.duoDuoData.goods_thumbnail_url ;//!商品主图
            this.addShopData.goods_gallery_urls = this.duoDuoData.goods_gallery_urls; // null;//!商品轮播图
            this.addShopData.mall_name = this.duoDuoData.mall_name; //! null;//店铺名称
            this.addShopData.category_id = this.duoDuoData.category_id; // !null;//商品类目ID
            this.addShopData.category_name = this.duoDuoData.category_name; // !null;//商品类目名
            this.addShopData.goods_eval_score = this.duoDuoData.goods_eval_score; // !5;//商品评分
            this.addShopData.min_group_price = this.duoDuoData.min_group_price; //!3250;//商品原价
            this.addShopData.coupon_discount = this.duoDuoData.coupon_discount; //!"30";//优惠券金额
            this.addShopData.coupon_total_quantity = this.duoDuoData.coupon_total_quantity; //!1000;//优惠券总数量
            this.addShopData.promotion_rate = this.duoDuoData.promotion_rate; //! "200";//佣金比例
            this.addShopData.sales_tip = this.duoDuoData.sales_tip; //!"500";//模糊销量（总数）
            // this.addShopData.goods_postCouponPrice = this.duoDuoData.goods_postCouponPrice; //??"500";//劵后价 这个是没有的要自己计算
            this.addShopData.coupon_remain_quantity = this.duoDuoData.coupon_remain_quantity; //!300;//优惠劵剩余
            this.addShopData.coupon_start_time = this.duoDuoData.coupon_start_time;// !1556035200;//优惠券生效时间
            this.addShopData.coupon_end_time = this.duoDuoData.coupon_end_time; //!1556207999;//优惠券失效时间
            this.addShopData.goods_desc = this.duoDuoData.goods_desc;//! "口罩";//导购文案
            /* this.addShopData.goods_whether = this.duoDuoData.goods_whether;// ??2;//当goods\_whether等于1的时候 单子通过 当等于0的时候单子不通过2等于待审核3是已下架
            this.addShopData.user_id = this.duoDuoData.user_id; //??18;//用户id
            this.addShopData.admin_id = this.duoDuoData.admin_id; //?null;//审核人的id */

            // ? 自己计算券后价 商品总价减去优惠券金额
          this.addShopData.goods_postCouponPrice = (this.addShopData.min_group_price - this.addShopData.coupon_discount);
          console.log('券后价',this.addShopData.goods_postCouponPrice);
      });
    },
    // 查询接口
    getAttract(){
      console.log('招商申请查询')
      this.axios.post("/getyzm/attract/index",qs.stringify({
          access_token:this.token,
        })).then(res => {
          console.log("招商申请查询请求回来的数据：", res);
      });
    },
    // 添加数据：个人或团队信息数据
    getAddData(){
      if(!this.attractData.monthMoney || !this.attractData.teamName || !this.attractData.teamQQ || !this.attractData.teamText || !this.attractData.teamWx){
        console.log('请正确输入提交信息');
        // 失败提示
        this.$notify.error({
          title: '提交失败',
          message: '请正确输入提交信息'
        });
      }else{
         this.isApply = true;
        this.axios.post("/getyzm/attract/add",{
              access_token:this.token,
              // 个人或团队
              collective_id:this.attractData.radio,
              // 个人或团体名称
              attract_collective:this.attractData.teamName,
              // qq
              attract_qq:this.attractData.teamQQ,
              // 微信号
              attract_wechat:this.attractData.teamWx,
              // 月收入
              attract_income:this.attractData.monthMoney,
              // 介绍
              attract_text:this.attractData.teamText,
          }).then(res => {
          console.log("添加个人团队信息回调：", res);
          // 保存申请状态
          this.ApiStorage.set('apply',res.data.data)
          this.isApply = true;
        });
      }
      console.log('提交个人信息',this.attractData);
    },
    // 查询商品接口
    getGoodsData(){
      console.log('获取信息')
      this.axios.post("/goods/index",{
              access_token:this.token,
          }).then(res => {
          console.log("查询商品获取信息接口", res);
      });
    },
    // 搜索商品接口
    getSelectData(){
      console.log('这个是搜索按钮，安照关键字查询的接口')
      console.log('输入框的数据',this.$refs.shopName.nativeInputValue);
      let theShopName = this.$refs.shopName.nativeInputValue
      this.isIssue = true;
      this.axios.post("/getyzm/goods/get_select",{
              access_token:this.token,
              // 商品名称
              goods_name:theShopName,
          }).then(res => {
          console.log("搜索商品回调：", res);
          // 保存数据
          this.guangLiData = res.data.data;
          this.isIssue = true;
      });
    },
    // 提交 -------------------------------------------------------------------------------添加商品数据
    getAllInofData(){
      // 获取时间
      console.log('查看要提交的数据',this.addShopData);
      console.log('token',this.token);
      this.axios.post("/getyzm/goods/add",{
              access_token:this.token,
              // 内容
              goods_name:this.addShopData.goods_name, //商品标题
              goods_id: this.addShopData.goods_id,//商品id
              goods_thumbnail_url: this.addShopData.goods_thumbnail_url,//商品主图
              goods_gallery_urls: this.addShopData.goods_gallery_urls,//商品轮播图
              mall_name: this.addShopData.mall_name,//店铺名称
              category_id: this.addShopData.category_id,//商品类目ID
              category_name:this.addShopData.category_name,//商品类目名
              goods_eval_score: this.addShopData.goods_eval_score,//商品评分
              min_group_price:this.addShopData.min_group_price ,//商品原价
              coupon_discount:this.addShopData.coupon_discount,//优惠券面额
              coupon_total_quantity: this.addShopData.coupon_total_quantity,//优惠券总数量
              promotion_rate:this.addShopData.promotion_rate,//佣金比例
              sales_tip:this.addShopData.sales_tip,//模糊销量（总数）
              goods_postCouponPrice: this.addShopData.goods_postCouponPrice,//!劵后价 这个要自己计算
              coupon_remain_quantity: this.addShopData.coupon_remain_quantity,//优惠劵剩余
              coupon_start_time:this.addShopData.coupon_start_time,//优惠券生效时间
              coupon_end_time: this.addShopData.coupon_end_time,//优惠券失效时间
              goods_desc:this.addShopData.goods_desc,//导购文案
              /* goods_whether: this.addShopData.goods_whether,//!当goods\_whether等于1的时候 单子通过 当等于0的时候单子不通过2等于待审核3是已下架
              user_id:this.addShopData.user_id,//!用户id
              admin_id: this.addShopData.admin_id,//!审核人的id,
              time: "2019-04-24 14:34:47"   //!提交时间 */
          }).then(res => {
          console.log("添加商品数据成功回调：", res);
      });
    },
    // 下拉框
    change2(){
      if(this.navBool){
        this.navBool = false;
      }else{
        this.navBool = true;
      }
    },
    person(){
      console.log('index',index);
    },
    // 获取侧边栏的导航下标
    getAsideIndex(){
      console.log('获取下标',this.asideIndex);
    },     
  },
  computed:{
    /* startTime(){
      let num = this.checkTime(this.addShopData.couponStartTime);
      this.addShopData.couponStartTime = num
      return ;
    } */
  }
};
</script>

